home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / util / check_close.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  666 b   |  34 lines

  1. /* check_close.c: close an fopen'd fd with lots of checks. */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/util/RCS/check_close.c,v 6.0 1991/12/18 20:25:18 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/util/RCS/check_close.c,v 6.0 1991/12/18 20:25:18 jpo Rel $
  9.  *
  10.  * $Log: check_close.c,v $
  11.  * Revision 6.0  1991/12/18  20:25:18  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16. #include "util.h"
  17.  
  18. extern int use_fsync;
  19.  
  20. int check_close (fp)
  21. FILE *fp;
  22. {
  23.  
  24.     if (fflush(fp) == EOF || ferror(fp))
  25.         return NOTOK;
  26. #ifdef HAS_FSYNC
  27.     if (use_fsync && fsync(fileno(fp)) == NOTOK)
  28.         return NOTOK;
  29. #endif
  30.     if (fclose (fp) == EOF)
  31.         return NOTOK;
  32.     return OK;
  33. }
  34.